# Copyright 2023 Ant Group Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("//bazel:serving.bzl", "serving_cc_library", "serving_cc_test")

package(default_visibility = ["//visibility:public"])

serving_cc_library(
    name = "oss_client",
    srcs = ["oss_client.cc"],
    hdrs = ["oss_client.h"],
    deps = [
        "@aws_sdk_cpp//:transfer",
        "@yacl//yacl/base:exception",
    ],
)

serving_cc_library(
    name = "sys_util",
    srcs = ["sys_util.cc"],
    hdrs = ["sys_util.h"],
    deps = [
        "//secretflow_serving/core:exception",
        "@openssl",
    ],
)

serving_cc_library(
    name = "utils",
    srcs = ["utils.cc"],
    hdrs = ["utils.h"],
    deps = [
        "//secretflow_serving/apis:error_code_cc_proto",
        "//secretflow_serving/apis:status_cc_proto",
        "//secretflow_serving/core:exception",
        "//secretflow_serving/protos:feature_cc_proto",
        "@protobuf//:json_util",
    ],
)

serving_cc_library(
    name = "arrow_helper",
    srcs = ["arrow_helper.cc"],
    hdrs = ["arrow_helper.h"],
    deps = [
        ":utils",
        "//secretflow_serving/core:exception",
        "//secretflow_serving/protos:data_type_cc_proto",
        "@arrow",
        "@yacl//yacl/base:buffer",
    ],
)

serving_cc_library(
    name = "csv_util",
    srcs = ["csv_util.cc"],
    hdrs = ["csv_util.h"],
    deps = [
        ":arrow_helper",
    ],
)

serving_cc_library(
    name = "csv_extractor",
    srcs = ["csv_extractor.cc"],
    hdrs = ["csv_extractor.h"],
    deps = [
        ":csv_util",
        "//secretflow_serving/spis:batch_feature_service_cc_proto",
    ],
)

serving_cc_library(
    name = "thread_safe_queue",
    hdrs = ["thread_safe_queue.h"],
    deps = [
        "//secretflow_serving/core:exception",
    ],
)

serving_cc_library(
    name = "thread_pool",
    hdrs = ["thread_pool.h"],
    deps = [
        ":thread_safe_queue",
    ],
)

serving_cc_test(
    name = "csv_extractor_test",
    srcs = ["csv_extractor_test.cc"],
    deps = [
        ":csv_extractor",
        "@brpc//:butil",
    ],
)

serving_cc_test(
    name = "arrow_helper_test",
    srcs = ["arrow_helper_test.cc"],
    deps = [
        ":arrow_helper",
    ],
)

serving_cc_library(
    name = "backoff_policy",
    hdrs = ["backoff_policy.h"],
    deps = [
        "//secretflow_serving/config:retry_policy_cc_config",
        "@brpc",
    ],
)

serving_cc_library(
    name = "retry_policy",
    srcs = ["retry_policy.cc"],
    hdrs = ["retry_policy.h"],
    deps = [
        ":backoff_policy",
        "//secretflow_serving/config:retry_policy_cc_config",
        "//secretflow_serving/core:exception",
        "//secretflow_serving/core:singleton",
        "@brpc",
    ],
)

serving_cc_library(
    name = "network",
    srcs = ["network.cc"],
    hdrs = ["network.h"],
    deps = [
        ":retry_policy",
        "//secretflow_serving/config:cluster_config_cc_proto",
        "//secretflow_serving/config:tls_config_cc_proto",
        "//secretflow_serving/core:exception",
        "@brpc",
    ],
)

serving_cc_test(
    name = "retry_policy_test",
    srcs = ["retry_policy_test.cc"],
    deps = [
        ":retry_policy",
        "//secretflow_serving/source:http_service_cc_proto",
    ],
)

serving_cc_test(
    name = "thread_safe_queue_test",
    srcs = ["thread_safe_queue_test.cc"],
    deps = [
        ":thread_safe_queue",
    ],
)

serving_cc_library(
    name = "he_mgm",
    srcs = ["he_mgm.cc"],
    hdrs = ["he_mgm.h"],
    deps = [
        "//secretflow_serving/core:exception",
        "//secretflow_serving/core:singleton",
        "@heu//heu/library/numpy",
    ],
)
